<%@ include file="/header.jsp" %>

<h1>Add new Album</h1>

<form:form commandName="album">

    <p><label for="title">Title</label><br/>
    <form:input path="title"/>
    <form:errors path="title" cssStyle="color: red"/>
    </p>

    <p><label for="year">Year</label><br/>
    <form:input path="year"/>
    <form:errors path="year" cssStyle="color: red"/>
    </p>

    <p><label for="artist.id">Artist</label><br/>
    <form:select path="artist.id">
    	<form:options items="${artists}" itemValue="id" itemLabel="name" />
    </form:select>
    <form:errors path="artist.id" cssStyle="color: red"/>
    </p>
    
    <p><label for="genres">Genres</label><br/>
    <form:select path="genres" multiple="true">
    	<form:options items="${genres}" itemValue="id" itemLabel="name" />
    </form:select>
    <form:errors path="genres" cssStyle="color: red"/>
    </p>
    <p><label for="review">Review</label><br/>
    <form:textarea path="review" rows="3" cols="20"/>
    <form:errors path="review" cssStyle="color: red"/>
    </p>

    
	<c:choose>
	<c:when test="${album.updateGranted}">
	<p><input type="submit" value="Save"/></p>
	</c:when>
	<c:otherwise>
	<p>Edit Not allowed</p>
	</c:otherwise>
	</c:choose> 
</form:form>
	<p>Album Genres</p>

	<table border="1" width="90%" cellspacing="0" style="margin:10px">
		<c:forEach items="${album.genres}" var="item">                
		<tr>
		<td><c:out value="${item.name}"/></td>
		</tr>
		</c:forEach>
	</table> 

<%@ include file="/footer.jsp" %>

